package com.example.yang.ministy;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.sam.widget.nav_bar.NavigationBar;

import com.example.yang.ministy.com.example.yang.Fragment.DiscoveryFragment;
import com.example.yang.ministy.com.example.yang.Fragment.MessageFragment;
import com.example.yang.ministy.com.example.yang.Fragment.mefragment;
import com.example.yang.ministy.com.example.yang.Fragment.WonderFragment;


/**
 * Created by Yang on 2016/9/21.
 */
public class MainframentActivitySDK extends FragmentActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragmentsdk);
        NavigationBar navigationBar=(NavigationBar)findViewById(R.id.nav_bar);
        NavigationBar.NavigationItemEntity[]items=new NavigationBar.NavigationItemEntity[]{
            new NavigationBar.NavigationItemEntity(this,R.string.nav_wonder,R.mipmap.nav_wonder_normal_ic,R.mipmap.nav_wonder_checked_ic),
            new NavigationBar.NavigationItemEntity(this,R.string.nav_discovery,R.mipmap.nav_discovery_normal_ic,R.mipmap.nav_discovery_checked_ic),
            new NavigationBar.NavigationItemEntity("",null,null),
            new NavigationBar.NavigationItemEntity(this,R.string.nav_message,R.mipmap.nav_message_normal_ic,R.mipmap.nav_message_checked_ic),
            new NavigationBar.NavigationItemEntity(this,R.string.nav_wonder,R.mipmap.nav_me_normal_ic,R.mipmap.nav_me_checked_ic),

        };
        final Fragment[] fragments=new Fragment[]{new WonderFragment(),new DiscoveryFragment(),null,new MessageFragment(),new mefragment()};
        NavigationBar.OnNavItemCheckedChangeListener onNavItemCheckedChangeListener=new NavigationBar.OnNavItemCheckedChangeListener() {
            @Override
            public void onCheckedChanged(NavigationBar navigationBar, int i, View view) {

                showFragment(fragments[i]);
            }
        };
        navigationBar.setNavigationItems(items,0,onNavItemCheckedChangeListener);
        navigationBar.setBackgroundColor(getResources().getColor(R.color.default_nav_bar_bg_color));


    }

    private void showFragment(Fragment fragment) {
        FragmentTransaction fragmenTransaction=getSupportFragmentManager().beginTransaction();
        fragmenTransaction.replace(R.id.flam,fragment);
        fragmenTransaction.commit();
    }


}

